<?php

class Core_Backend_Domain extends Dcmp_Domain_Base{

	protected $name = 'backend';
	
	public function loadComponent($name){
		$componentClass = $this->getName().'_component_'.$name.'_'.$name;
		$componentClass = Kd_Loader::loadClass($componentClass);
		$componentClass = empty($componentClass)?
                                'Core_Backend_Share_Component':
                                $componentClass;
		return new $componentClass($this);
	}	
	
	protected function initialize() {
        $themeName = 'default';
        $skinName = 'default';
        $templatePaths = array(DP_DESIGN . strtolower($this->getName()) . DS . $themeName . DS);
        $htmlPaths = array(DP_DESIGN . strtolower($this->getName()) . DS . $themeName . DS . 'html' . DS);
        
		$this->getConfig()->setSetting('themeName', $themeName);
		$this->getConfig()->setSetting('skinName', $skinName);
		$this->getConfig()->setSetting('templateDirectories', $templatePaths);
		
		$localizeCode = $this->getApplication()->getConfig()->getSetting('localize');
		$this->getConfig()->setSetting('localizeCode', $localizeCode);
        Kd_Html_Config::setTemplatePaths($htmlPaths);
        Kd_Localize_Config::setLocalizeCode($localizeCode);
        $files = Kd_Util_IO::getFiles(DP_LOCALIZE . $localizeCode);
        foreach ($files as $file) {
            Kd_Localize_Factory::getTranslator()->loadFile($file['name'], $file['filename']);
        }

		parent::initialize();
	}
}